package com.wxq.koland.xiaoliscan.network;

import com.google.gson.Gson;
import com.wxq.koland.xiaoliscan.bean.NormalBean;
import com.wxq.koland.xiaoliscan.bean.UserInfo;
import com.wxq.koland.xiaoliscan.utils.LogUtil;
import com.wxq.koland.xiaoliscan.utils.SHAUtil;

import java.util.HashMap;
import java.util.Map;

import okhttp3.RequestBody;
import retrofit2.Callback;

/**
 * 项目请求再次封装 归纳类
 */
public class RequestUtils {

    private static Gson gson ;

    private static Gson getGson(){
        if (gson == null){
            synchronized (RequestUtils.class){
                if (gson == null){
                    gson = new Gson();
                }
            }
        }
        return gson ;
    }


    /**
     * Post 登录
     * @param callback
     */
    public static void postUser(String passCode,String mac, Callback<UserInfo> callback){
            Map<String,String> map = new HashMap<>();
            map.put("qrData", passCode);
            map.put("mac",mac);
            RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8")
                        ,getGson().toJson(map));
            LogUtil.d(getGson().toJson(map));
            RetrofitUtils.getApiService()
                        .getUserInfo(requestBody).enqueue(callback);
    }

}